<template>
<div>
  <h1>等你妈的路</h1>
  <p>账号：<input type="text" v-model="form.username"></p>
  <p>密码：<input type="text" v-model="form.password"></p>
  <button @click="login">登录</button>
  <button @click="sanfang">微信登录</button>

</div>
</template>

<script>
export default {
  name: "login",
  data(){
  return{
  form:{},
  ltoken:"",
  luid:""
  }
  },
  methods:{
  sanfang(){
  this.$axios.get('/login/uidtoken')
  .then(res=>{
  if(res.data.code==200){
  this.luid = res.data.luid
  this.ltoken = res.data.ltoken
  alert(this.ltoken)
  this.$router.push({path:'/sanfang',query:{'luid':this.luid,'ltoken':this.ltoken}})
  }
  })


  },
  login(){
  this.$axios.post('/login/login',this.form).then(res=>{
  if(res.data.code==200){
  alert('登录成功')
  localStorage.setItem('userid',res.data.userid)
  localStorage.setItem('username',res.data.username)
  }
  else {
  alert(res.data.mes)
  }

  })
  }
  }
}
</script>

<style scoped>

</style>
